﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="freightWay.aspx.cs" Inherits="WebApp.admin.basic.freightWay" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
	
        
</title><link href="../css/skin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/main.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>

<script type="text/javascript">
   
   function checkFreightWayForm()
   {

            var selectFreightTemplate = document.getElementById("ddlFreightTemplate");
            if (selectFreightTemplate.options[selectFreightTemplate.selectedIndex].value == "") {
                alert("请选择运费模版！");
                selectFreightTemplate.focus();
                return false;
            }

            var selectDeliveryWay = document.getElementById("ddlDeliveryWay");
            if (selectDeliveryWay.options[selectDeliveryWay.selectedIndex].value == "") {
                alert("请选择配送方式！");
                selectDeliveryWay.focus();
                return false;
            }

            if ($("#txtDefaultFreight").val() == "") {
                $("#txtDefaultFreight").select();
                alert("请输入首件商品运费！");
                return false;
            }
            return true;


    }




    $(function () {



        var sc = document.getElementById("selectRegion");
        var sac = document.getElementById("selectAddRegion");
        $("#btnAllAdd").click(function () {
            for (var i = 0; i < sc.options.length; i++) {
                var rs = false;
                for (var j = 0; j < sac.options.length; j++) {
                    if (sac.options[j].value == sc.options[i].value)
                        rs = true;
                }
                if (!rs) {
                    var selectItem = new Option();
                    if (sc.options[i].text.indexOf("┣") != -1)
                        selectItem.text = sc.options[i].text.substring(sc.options[i].text.indexOf("┣") + 1);
                    else
                        selectItem.text = sc.options[i].text;
                    selectItem.value = sc.options[i].value
                    sac.options.add(selectItem);
                }
            }
            setRegion();
        });
        $("#btnAdd").click(function () {
            for (var i = 0; i < sc.options.length; i++) {
                if (sc.options[i].selected) {
                    var rs = false;
                    for (var j = 0; j < sac.options.length; j++) {
                        if (sac.options[j].value == sc.options[i].value)
                            rs = true;
                    }
                    if (!rs) {
                        var selectItem = new Option();
                        if (sc.options[i].text.indexOf("┣") != -1)
                            selectItem.text = sc.options[i].text.substring(sc.options[i].text.indexOf("┣") + 1);
                        else
                            selectItem.text = sc.options[i].text;
                        selectItem.value = sc.options[i].value
                        sac.options.add(selectItem);

                    }
                }
            }
            setRegion();
        });
        $("#btnDelete").click(function () {
            for (var i = (sac.options.length - 1); i > -1; i--) {
                if (sac.options[i].selected) {
                    sac.options.remove(i);
                }
            }
            setRegion();
        });
        $("#btnAllDelete").click(function () {
            for (var i = (sac.options.length - 1); i > -1; i--) {
                sac.options.remove(i);
            }
            setRegion();
        });

        function setRegion() {
            var sac = document.getElementById("selectAddRegion");
            var hidRegionValues = document.getElementById("hidRegion");
            if (sac.options.length != 0) {
                var cid = "";
                for (var j = 0; j < sac.options.length; j++) {
                    if (j == 0)
                        cid += sac.options[j].value;
                    else
                        cid += "," + sac.options[j].value;
                }

                hidRegionValues.value = cid;
            }
        }

    });
</script>
</head>

<body class="body">
    <table class="main" cellpadding="0" cellspacing="0">
        <tr>
            <td class="td_middle_middle">
                <div class="maincontent">
                    <form id="form1" runat="server" enctype="multipart/form-data">

                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                            <tr>
                                <td class="td_title">
                                    运费模版：</td>
                                <td class="td_content">
                                     <asp:DropDownList ID="ddlFreightTemplate" runat="server"></asp:DropDownList>
                                    *</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    配送方式：</td>
                                <td class="td_content">
                                    <asp:DropDownList ID="ddlDeliveryWay" runat="server"></asp:DropDownList>
                                    *</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    默认运费：</td>
                                <td class="td_content">
                                    <input name="txtDefaultFreight" runat="server" type="text" id="txtDefaultFreight" />元 *【首件商品运费】</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    增加运费：</td>
                                <td class="td_content">
                                    <input name="txtIncreasedFreight" runat="server" type="text" id="txtIncreasedFreight" />元 【每超过一件商品增加运费】</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    指定地区：</td>
                                <td class="td_content">
                                             <table>
                                            <tr>
                                                <td style="width: 280px;">
                                                    <select id="selectRegion" name="Region" multiple="multiple" class="select">
                                                        <%Response.Write(RegionBind()); %>
                                                    </select>
                                                </td>
                                                <td style="text-align: center; width: 120px;">
                                                    <input id="btnAllAdd" type="button" value="添加所有" title="添加所有分类" class="formButton" /><br />
                                                    <br />
                                                    <input id="btnAdd" type="button" value="添加选取" title="添加选取分类" class="formButton" /><br />
                                                    <br />
                                                    <input id="btnDelete" type="button" value="移除选取" title="移除选取分类" class="formButton" /><br />
                                                    <br />
                                                    <input id="btnAllDelete" type="button" value="移除所有" title="移除所有分类" class="formButton" />
                                                </td>
                                                <td>
                                                    <select id="selectAddRegion"  name="addRegion"   multiple="multiple" class="select">
                                                        <%Response.Write(RegionRightBind()); %>
                                                    </select>
                                                    <input type="hidden" id="hidRegion" name="hidRegion" value="" />
                                                </td>
                                            </tr>
                                        </table>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                 <asp:Button ID="btnSubmit" runat="server" Text="确  定" CssClass="formButton" OnClientClick="return checkFreightWayForm()" OnClick="btnSubmit_Click"  />&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input id="btnBack" type="button" class="formButton" value=" 返  回 " onclick="location.href='freightWayList.aspx?tid=<%= tid %>&gid=<%= gid %>';" /></td>
                            </tr>
                        </table>             
</form>
                </div>
            </td>

        </tr>

    </table>
</body>
</html>

